package com.caltco.cargo.ops.auth.bo;

import com.caltco.cargo.ops.auth.entity.UserEntity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @program: agilefast-framework
 * @description: SpringSecurity 用户信息
 * @author: yehao
 * @create: 2022-07-21 08:43
 **/
public class AdminUserDetails implements UserDetails {

    // 系统用户
    private UserEntity userEntity;
    // token
    private String token;

    public AdminUserDetails(UserEntity userEntity){
        this.userEntity = userEntity;
    }

    public AdminUserDetails(UserEntity userEntity, String token) {
        this.userEntity = userEntity;
        this.token = token;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return userEntity.getPassword();
    }

    @Override
    public String getUsername() {
        return userEntity.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return false;
    }

    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    @Override
    public boolean isEnabled() {
        return false;
    }

    public UserEntity getUserEntity() {
        return userEntity;
    }

    public void setUserEntity(UserEntity userEntity) {
        this.userEntity = userEntity;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }
}
